module(
    name = "rules_jsonnet",
    version = "0.7.1",
)

bazel_dep(name = "bazel_skylib", version = "1.8.0")
bazel_dep(name = "jsonnet", version = "0.21.0")
bazel_dep(name = "jsonnet_go", version = "0.21.0")
bazel_dep(name = "rules_python", version = "1.5.0")
bazel_dep(name = "rules_rust", version = "0.62.0")

jsonnet = use_extension("//jsonnet:extensions.bzl", "jsonnet")
use_repo(jsonnet, "rules_jsonnet_toolchain")

register_toolchains("@rules_jsonnet_toolchain//:toolchain")

rust_host = use_extension("@rules_rust//rust:extensions.bzl", "rust_host_tools")
rust_host.host_tools(
    name = "rust_host_tools_jsonnet",
    sha256s = {
        "2025-07-01/rustc-nightly-aarch64-apple-darwin.tar.xz": "b5fb4b5272fea4d4ef6e3896e484e9748fda4f29be428ae3a55c22f70566b54c",
        "2025-07-01/clippy-nightly-aarch64-apple-darwin.tar.xz": "a0715713220f6cb56031a86c91de7a26d1f89d149afc2e01af625a89ca63f673",
        "2025-07-01/cargo-nightly-aarch64-apple-darwin.tar.xz": "4eb240f69df9f9159c6fef128c3b7c24e5e1ae8aaf1357de4924fd518bd54941",
        "2025-07-01/llvm-tools-nightly-aarch64-apple-darwin.tar.xz": "ab8d9977ba3187819008b70dab317654bb290fc220cfea35b4f2ea165ce32e70",
        "2025-07-01/rust-std-nightly-aarch64-apple-darwin.tar.xz": "da6c8e6f256bb6512485db068d35109a3c77ccac678bc28134665cd1b547863b",
    },
    version = "nightly/2025-07-01",
)
use_repo(rust_host, "rust_host_tools_jsonnet")

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
    edition = "2021",
    versions = ["1.88.0"],
)
use_repo(rust, "rust_toolchains")

register_toolchains("@rust_toolchains//:all")

crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
crate.spec(
    # Binary artifacts can't be depended upon without specifically marking the
    # artifact as `bin`.
    artifact = "bin",
    package = "jrsonnet",
    version = "0.5.0-pre95",
)

# Required for rules_rust to generate binary targets for the Jrsonnet crate.
crate.annotation(
    crate = "jrsonnet",
    gen_binaries = ["jrsonnet"],
)
crate.from_specs(
    host_tools = "@rust_host_tools_jsonnet",
)
use_repo(crate, "crates")
